<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">会员充值账户流水</h2>
        <span class="layui-breadcrumb pull-right">
          <a href="#!home">首页</a>
          <a><cite>会员充值账户流水</cite></a>
        </span>
    </div>
    <div class="layui-card-body">
        <div class="layui-form toolbar">
                      搜索：  <select id="memberrechargerecord-search-key">
            <option value="">-请选择-</option>
                 <!--<option value="id"></option>-->
                 <!--<option value="recharge_code">编号</option>-->
                 <option value="member_id">会员ID</option>
                 <!--<option value="create_time">充值时间</option>-->
                 <!--<option value="recharge_money">账户充值金额</option>-->
                 <!--<option value="recharge_balance">充值账户后余额</option>-->
                 <!--<option value="type">1,充值 2,支付佣金 3,冻结佣金</option>-->
                 <!--<option value="comment">流水描述</option>-->
                 <!--<option value="pay_no"></option>-->
                 <!--<option value="status">0 未支付 1 已支付</option>-->
                 <!--<option value="business_id">充值 商家</option>-->
                 <!--<option value="pay_order_id">支付订单 ID</option>-->
                 <!--<option value="recharge_id">充值套餐ID</option>-->
                 <!--<option value="giverecharge_money">账户赠送金额</option>-->
                 </select>&emsp;
            <input id="memberrechargerecord-search-value" class="layui-input search-input" type="text" placeholder="输入关键字"/>&emsp;
            <button id="memberrechargerecord-btn-search" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
        </div>

        <table class="layui-table" id="memberrechargerecord-table" lay-filter="memberrechargerecord-table"></table>
    </div>
</div>


<!-- 表格操作列 -->
<script type="text/html" id="memberrechargerecord-table-bar">
 {{#   if(admin.hasPerm("member:memberrechargerecord:update") ){   }}
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
 {{#     } }} 
 <!--{{#  if(admin.hasPerm("member:memberrechargerecord:delete") ){   }}-->
    <!--<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>-->
 <!--{{#     } }} -->
</script>
<script type="text/html" id="strType">
    {{#   if(d.type==1){   }}
    <label class="layui-form-label">充值</label>
    {{#     } }}
    {{#   if(d.type==2){   }}
    <label class="layui-form-label">支付佣金</label>
    {{#     } }}
    {{#   if(d.type==3){   }}
    <label class="layui-form-label">冻结佣金</label>
    {{#     } }}
</script>
<script type="text/html" id="strStatus">
    {{#   if(d.status==0){   }}
    <label class="layui-form-label">未支付</label>
    {{#     } }}
    {{#   if(d.status==1){   }}
    <label class="layui-form-label">已支付</label>
    {{#     } }}
    {{#   if(d.status==null){   }}
    <label class="layui-form-label">未支付</label>
    {{#     } }}
    {{#   if(d.status==3){   }}
    <label class="layui-form-label">已支付</label>
    {{#     } }}
</script>
<!--<script type="text/html" id="toolbar">-->
     <!--{{#  if(admin.hasPerm("member:memberrechargerecord:save")){ }}-->
     <!--<button id="memberrechargerecord-btn-add" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>-->
     <!--{{#     } }} -->
 <!---->
<!--</script>-->

<script>
   var admin;
    layui.use(['form', 'table', 'util', 'config', 'admin', 'upload','laytpl','element' ], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
          admin = layui.admin;
        //上传
        var upload = layui.upload;
        let laytpl = layui.laytpl;
        let element = layui.element;

        // 渲染表格
        table.render({
            elem: '#memberrechargerecord-table',
            url: config.base_server + 'member/memberrechargerecord/listforweb',
            method: 'GET',
       
            page: true,
            cols: [[
                {type: 'numbers'},
                           // {field: 'id', sort: true, title: ''},
                           // {field: 'rechargeCode', sort: true, title: '编号'},
                           {field: 'userName', sort: false, title: '会员名称'},
                           {field: 'createTime', sort: false, title: '充值时间'},
                           {field: 'rechargeMoney', sort: false, title: '账户充值金额'},
                           {field: 'rechargeBalance', sort: false, title: '充值账户后余额'},
                           {field: 'type', sort: false, title: '类型',toolbar:'#strType'},
                           // {field: 'comment', sort: true, title: '流水描述'},
                           {field: 'payNo', sort: false, title: '支付凭证'},
                           {field: 'status', sort: false, title: '支付状态',toolbar:'#strStatus'},
                           {field: 'businessName', sort: false, title: '充值商家'},
                           {field: 'payOrderId', sort: false, title: '支付订单'},
                           {field: 'rechargeId', sort: false, title: '充值套餐'},
                           {field: 'giverechargeMoney', sort: false, title: '赠送金额'},
                        
                {fixed: 'right', align: 'center', toolbar: '#memberrechargerecord-table-bar', title: '操作', width: 175}
            ]]
        });
        
        // laytpl($("#toolbar")[0].innerHTML).render({ }, function(html){
		// 	  $(".layui-card-body .toolbar").append(html);
		// 	  element.render('nav');
		//   });

        // 添加按钮点击事件
        // $('#memberrechargerecord-btn-add').click(function () {
        //     showEditModel();
        // });

        // 工具条点击事件
        table.on('tool(memberrechargerecord-table)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;

            if (layEvent === 'edit') { // 修改
             
                showEditModel(data);
            }  else if (layEvent === 'del') { // 删除
                layer.confirm('确定删除吗？', function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('member/memberrechargerecord/delete/'+obj.data.id, {}, function (data) {
                        layer.closeAll('loading');
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 500});
                            table.reload('memberrechargerecord-table', {});
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 500});
                        }
                    }, 'delete');
                });
            }
        });

        //显示表单弹窗
        var showEditModel = function (data) {
        	  var title = data ? '修改记录' : '添加记录';
            //修改方法名
            if (data){
                data.method="update"
            }else{
            	data={method:"save"};
            }
 
            admin.putTempData('t_memberrechargerecord', data);
            admin.popupCenter({
                title: title,
                path: 'pages/member/memberrechargerecord_form.html',
                finish: function () {
                    table.reload('memberrechargerecord-table', {});
                }
            });
        };

        // 搜索按钮点击事件
        $('#memberrechargerecord-btn-search').click(function () {
            var key = $('#memberrechargerecord-search-key').val();
            var value = $('#memberrechargerecord-search-value').val();
            table.reload('memberrechargerecord-table', {where: {searchKey: key, searchValue: value}});
        });

    });
</script>
